<template>
  <el-tabs v-model="tabTag" type="card" :before-leave="doBeforeLeave">
    <el-tab-pane label="审核" name="audit">
      <auditForm ref="auditForm" />
    </el-tab-pane>
    <el-tab-pane label="新品Retry" name="newItemRetry">
      <newItemRetryForm ref="newItemRetryForm" />
    </el-tab-pane>
    <el-tab-pane label="新品紧急出号" name="urgent">
      <urgentForm ref="urgentForm" />
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import auditForm from '@/views/item-file/audit/list'
import newItemRetryForm from '@/views/item-file/retry/newItemList'
import urgentForm from '@/views/item-file/urgent/list'

export default {
  components: { auditForm, urgentForm, newItemRetryForm },
  data() {
    return {
      tabTag: 'audit'
    }
  },
  methods: {
    // 切换tab触发
    doBeforeLeave(activeName, oldActiveName) {
      if (activeName === 'audit') {
        this.$refs.auditForm.toQuery()
      } else if (activeName === 'newItemRetry') {
        this.$refs.newItemRetryForm.toQuery()
      } else if (activeName === 'urgent') {
        this.$refs.urgentForm.toQuery()
      }
    }
  }
}
</script>

